////////////////////////////////////////////////////////////////////////////////
//                                                                            //
//                           BailterRay                                       //
//                    Pip Robbins & Zhao Zhang                                //
//                                                                            //
////////////////////////////////////////////////////////////////////////////////
class BailterRayInteraction extends Interaction
	dependson(BailterRayPlayerController)
	config(BailterRay);

var BailterRayPlayerController MPC;

// Custom Keys or Commands
var config name JumpKey,DodgeKey,CrouchKey;
var config name ConsoleDodgeKey;
var config name ConsoleJumpKey1,ConsoleJumpKey2,ConsoleLeftStickX, ConsoleLeftStickY,ConsoleCrouchKey,ConsoleDummyKey, ConsoleAimKeyY,ConsoleAimKeyX;


function Initialized() {
	OnReceivedNativeInputKey = CheckMyKeyInput;   // delegation stuff
	OnReceivedNativeInputAxis = CheckMyAxis;
}

function bool CheckMyAxis(int ControllerId, name Key, float Delta, float DeltaTime, optional bool bGamepad )
{
     if(Key == ConsoleLeftStickY)
     {
         MPC.Controller_LeftY = Delta;
     }

     if(Key == ConsoleLeftStickX)
     {
         MPC.Controller_LeftX = Delta;
     }

     if(Key == ConsoleAimKeyY )
     {
         MPC.Controller_RightX = Delta;
     }
     if(Key == ConsoleAimKeyX )
     {
         MPC.Controller_RightY = Delta;
     }
     return false;
}

function bool CheckMyKeyInput(int ControllerId, name Key, EInputEvent EventType, optional float AmountDepressed=1.f, optional bool bGamepad) {
	if(Key == JumpKey || Key == ConsoleJumpKey1 || Key == ConsoleJumpKey2 ) {
		if (EventType == IE_Pressed ) {
			MPC.MyJump();
			return true;
		}

		if (EventType == IE_Released ) {
			return true;
		}
	}
	if(Key == CrouchKey || Key == ConsoleCrouchKey){
		if (EventType == IE_Pressed) {
		    MPC.MyStartCrouch();
			return true;
		}

		if (EventType == IE_Released) {
		    MPC.MyEndCrouch();
			return true;
		}
	}
	if(Key == DodgeKey) {
		if (EventType == IE_Pressed) {
		    MPC.MyDodge();
			return true;
		}

		if (EventType == IE_Released) {
			return true;
		}
	}
	if(Key == ConsoleDodgeKey) {
		if (EventType == IE_Pressed) {
		    MPC.MyDodge();
			return true;
		}

		if (EventType == IE_Released) {
			return true;
		}
	}
	if(Key == ConsoleDummyKey) {
		if (EventType == IE_Pressed) {

			return true;
		}

		if (EventType == IE_Released) {
			return true;
		}
	}
	return false;
}

DefaultProperties
{
    //default keys, but user can change these in .ini
    JumpKey=W
    DodgeKey=SpaceBar
    CrouchKey=S
    ConsoleDodgeKey=XboxTypeS_RightShoulder
    ConsoleJumpKey1=XboxTypeS_B
    ConsoleJumpKey2=XboxTypeS_LeftTrigger
    ConsoleCrouchKey= XboxTypeS_A
    ConsoleDummyKey=XboxTypeS_DPad_Left
    ConsoleLeftStickY=XboxTypeS_LeftY
    ConsoleLeftStickX=XboxTypeS_LeftX
    ConsoleAimKeyY=XboxTypeS_RightY
    ConsoleAimKeyX=XboxTypeS_RightX

}